﻿Imports System.Data
Imports System.Data.SqlClient
'Hacemos referencia al proyecto BusinessEntities
Imports BE = BusinessEntities

Public Class ContadorDAO
    Dim conexion As SqlConnection
    Dim comando As SqlDataAdapter
    Public Shared errores As String
    Dim com As SqlCommand

    'Instanciamos la clase Conexion
    Dim cn As New Conexion


    Public Function IncrementarVisitas() As Boolean

        Try
            conexion = cn.Conectar
            comando = New SqlDataAdapter("SP_INCREMENTARVISITAS", conexion)
            comando.SelectCommand.CommandType = CommandType.StoredProcedure

            '------------falta  verifivcar si falta executenonquery
        Catch ex As Exception
            errores = ex.Message
        Finally
            conexion.Dispose()
            comando.Dispose()
        End Try

    End Function

    Public Function MostrarVisitas() As DataSet

        Dim ds As New DataSet
        Try
            conexion = cn.Conectar
            comando = New SqlDataAdapter("SP_MOSTRARVISITAS", conexion)
            comando.SelectCommand.CommandType = CommandType.StoredProcedure

            'Dim ds As New DataSet
            comando.Fill(ds, "Visitas")

        Catch ex As Exception
            errores = ex.Message
        Finally
            conexion.Dispose()
            comando.Dispose()
            ds.Dispose()
        End Try

        Return ds

    End Function

    Public Function ChapaError() As String
        Return errores
    End Function

End Class
